<template>
  <div id="app">
    <particles-background v-if="showParticles"></particles-background>
    <router-view v-slot="{ Component, route }">
      <transition name="page-fade" mode="out-in">
        <component :is="Component" :key="route.path" @login-success="handleLoginSuccess" />
      </transition>
    </router-view>
  </div>
</template>

<script>
import ParticlesBackground from '@/components/ParticlesBackground.vue';
import { ref, watch } from 'vue';
import { useRoute } from 'vue-router';

export default {
  name: 'App',
  components: {
    ParticlesBackground
  },
  setup() {
    const showParticles = ref(true); // Default to true, will be always true now
    const route = useRoute();

    const handleLoginSuccess = (/* username */) => {
      // Particles are now shown on all main views based on current logic
    };

    // Particles are always on (Login and Chat) based on the requirements.
    // If specific routes should not have particles, adjust here.
    watch(()=> route.name, (routeName) => {
      if (routeName === 'Login' || routeName === 'Chat') {
        showParticles.value = true;
      } else {
        // For any other potential routes, decide if particles should be off
        showParticles.value = false; // Example: hide on a settings page
      }
    }, { immediate: true });

    return {
      showParticles,
      handleLoginSuccess
    };
  }
};
</script>

<style>
#app {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh;
  overflow: hidden; /* Important to prevent double scrollbars */
  position: relative; /* For transitions to work correctly within */
}
body {
  margin: 0;
  padding: 0;
  overflow: hidden; /* Prevent body scrollbars if #app is 100vh */
}

/* Page transition styles are now in styles.css */
</style>
